package com.tedu.openmedical.medicalsystem.sysDictDetail.controller;

import com.tedu.openmedical.base.response.JsonResult;
import com.tedu.openmedical.medicalsystem.sysDictDetail.pojo.VO.SysDictDetailDataVO;
import com.tedu.openmedical.medicalsystem.sysDictDetail.pojo.dto.DictDetailQuery;
import com.tedu.openmedical.medicalsystem.sysDictDetail.pojo.dto.DictDetailSaveParam;
import com.tedu.openmedical.medicalsystem.sysDictDetail.service.SysDictDataDetailService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@Slf4j
@Api(tags = "字典详情管理")
@RequestMapping("/v1/medical/medicalSystem/")
public class SysDictDataDetailController {

    @Autowired
    private SysDictDataDetailService sysDictDataDetailService;

    @GetMapping("selectDictDetail")
    @ApiOperation(value = "查询字典数据", notes = "查询字典数据")
    public JsonResult selectDictList(DictDetailQuery dictDetailQuery) {
        log.debug("dictDetailQuery: {}", dictDetailQuery);
        List<SysDictDetailDataVO> dictDetailList = sysDictDataDetailService.selectDictDetailList(dictDetailQuery);
        return JsonResult.ok(dictDetailList);
    }

    @PostMapping("save")
    @ApiOperation(value = "保存字典数据", notes = "保存字典数据")
    public JsonResult save(DictDetailSaveParam dictDetailSaveParam) {
        log.debug("dictDetailSaveParam: {}", dictDetailSaveParam);
        sysDictDataDetailService.save(dictDetailSaveParam);
        return JsonResult.ok();
    }

    @PostMapping("deleteDictDetail")
    @ApiOperation(value = "删除字典数据", notes = "删除字典数据")
    public JsonResult deleteDictDetail(Long id) {
        log.debug("id: {}", id);
        sysDictDataDetailService.deleteDictDetail(id);
        return JsonResult.ok();
    }
}
